/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * RSGeometricElement.h
 *
 *  Created on: 2010/02/16
 *      Author: Alexandre Pires ( c.alexandre.pires@gmail.com )
 */

#ifndef RSGEOMETRICELEMENT_H_
#define RSGEOMETRICELEMENT_H_

#include "RSElement.h"

namespace Realsphere {

    class RSGeometricElement: public Realsphere::RSElement {
        Q_OBJECT
        public:
            RSGeometricElement ( RSGeometricElementType rGeometricElementType );
            virtual ~RSGeometricElement();

        public:
            RSSource*               GetSource ( unsigned int rIndex );
            RSSource*               GetSource ( const QString& rId );
            int                     IndexOf ( RSSource* rSource );
            unsigned int            SourcesSize ();
            RSSources               Sources () const;
            RSSourcesIterator       SourcesIterator () const;
            bool                    IsRootElement () const;
            RSGeometricElementType  GeometricElementType ();

        public slots:
            RSError                 AddSource ( RSSource* rSource );
            RSError                 RemoveSource ( RSSource* rSource );
            RSError                 RemoveSource ( const QString& rId );
            RSError                 RemoveSource ( unsigned int rIndex );

        signals:
            void                    SourceAdded ( RSGeometricElement* rGeometricElement, RSSource* rDataSource );
            void                    SourceRemoved ( RSGeometricElement* rGeometricElement, RSSource* rDataSource );

        protected:
            virtual RSError         BeforeAddChildElement ( RSElement* rChild );
            virtual bool            AfterAddChildElement ( RSElement* rChild );
            virtual bool            AfterRemoveChildElement ( RSElement* rChild );

        public:
            static QString                  GeometricElementTypeToTag ( RSGeometricElementType rGeometricElementType );
            static RSGeometricElementType   GeometricElementTagToType ( const QString& rTag );

        private:
            RSSources               mSources;
            RSGeometricElementType  mGeometricElementType;
    };

}

#endif /* RSGEOMETRICELEMENT_H_ */
